﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.UnityExtensions;
using System.Windows;
using Microsoft.Practices.Composite.Modularity;
using Elentok.Common;
using Microsoft.Practices.Unity;
using Elentok.Common.Wpf;
using Elentok.Common.Wpf.ViewModels;
using Elentok.Common.Wpf.Services;

namespace AMail.Start
{
  public class Bootstrapper : UnityBootstrapper
  {
    protected override DependencyObject CreateShell()
    {
      Shell shell = Container.Resolve<Shell>();
      shell.Show();
      return shell;
    }

    protected override void ConfigureContainer()
    {
      base.ConfigureContainer();

      // registers the common services and view models
      this.Container.RegisterInstance<IRecentFilesService>(new RecentFilesService());
      this.Container.RegisterType<ICommonDialogsService, CommonDialogsService>(new ContainerControlledLifetimeManager());
      this.Container.RegisterType<IKeybindingService, KeybindingService>(new ContainerControlledLifetimeManager());
      this.Container.RegisterType<IMenuService, MenuService>(new ContainerControlledLifetimeManager());
      this.Container.RegisterType<IRecentFilesViewModel, RecentFilesViewModel>();

      this.Container.RegisterType<IShellViewModel, ShellViewModel>();
    }

    protected override IModuleCatalog GetModuleCatalog()
    {
      ModuleCatalog catalog = new ConfigurationModuleCatalog();
      return catalog;
    }
  }
}
